//
//  MainViewController.swift
//  swift新浪微博
//
//  Created by sunchanggui on 15/7/28.
//  Copyright © 2015年 sunchanggui. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()
    }
    
    func addChildViewControllers() {
        tabBar.tintColor = UIColor.orangeColor()
        
        //addChildViewController("Main", "首页", "tabbar_home")
        addChildViewController("Home", "首页", "tabbar_home")
        addChildViewController("Message", "消息", "tabbar_message_center")
        addChildViewController("Discover", "发现", "tabbar_discover")
        addChildViewController("Profile", "我", "tabbar_profile")
    }
    
    func addChildViewController(sbName: String, _ title: String, _ imageName: String) {
        let sb = UIStoryboard(name: sbName, bundle: nil)
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        
        nav.title = title
        nav.topViewController?.title = title
        nav.tabBarItem.image = UIImage(named: imageName)
        nav.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")
        
        addChildViewController(nav)
    }

}
